import 'package:flutter/widgets.dart';
import 'package:get/get.dart';
import '../../home/views/home_view.dart';
import '../../category/views/category_view.dart';
import '../../give/views/give_view.dart';
import '../../cart/views/cart_view.dart';
import '../../user/views/user_view.dart';

// import 'package:jpush_flutter/jpush_flutter.dart';

class TabsController extends GetxController {
  // 用于控制默认加载的tabs选项
  RxInt currentIndex = 0.obs;
  PageController pageController = PageController(
      initialPage: Get.arguments != null ? Get.arguments["initialPage"] : 0);
  final List<Widget> pages = [
    const HomeView(),
    const CategoryView(),
    const GiveView(),
    CartView(),
    const UserView()
  ];

  @override
  void onInit() {
    super.onInit();

    if (Get.arguments != null) {
      currentIndex.value = Get.arguments["initialPage"];
    }

    // initJPush();
  }

  @override
  void onClose() {
    super.onClose();
  }

  setCurrentIndex(index) {
    currentIndex.value = index;
    update();
  }

  /**
  initJPush() async {
    print("---initJpush---");
    JPush jpush = new JPush();
    jpush.setup(
      appKey: "9bd39e3546a6ef1fafd08d14",
      channel: "theChannel",
      production: false,
      debug: false, // 设置是否打印 debug 日志
    );
    jpush.getRegistrationID().then((rid) {
      print("注册的rid${rid}");
    });

    //设置别名  实现指定用户推送
    jpush.setAlias("Duanzihuang").then((map) {
      print("设置别名成功");
    });

    jpush.addEventHandler(
      // 接收通知回调方法。
      onReceiveNotification: (Map<String, dynamic> message) async {
        print("flutter onReceiveNotification: $message");
      },
      // 点击通知回调方法。
      onOpenNotification: (Map<String, dynamic> message) async {
        print("flutter onOpenNotification: $message");
      },
      // 接收自定义消息回调方法。
      onReceiveMessage: (Map<String, dynamic> message) async {
        print("flutter onReceiveMessage: $message");
      },
    );
  }
   */
}
